package cn.fzkj.springboot.config;

import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Method;
import java.util.Arrays;

@Configuration
public class CacheKeyGenerator {

    @Bean("myKeyGenerator")
    public KeyGenerator keyGenerator(){
        return new KeyGenerator(){
            @Override
            public Object generate(Object o, Method method, Object... objects) {
                System.out.println("开始自定义key的生成策略。。。。。。。。。。。");
                return method.getName()+"["+ Arrays.asList(objects).toString() +"]";
            }
        };
    }


}
